#ifndef __RGB32_H__
#define __RGB32_H__

#include <stdint.h>

#define RGBA_RED   0xFF0000FF
#define RGBA_GREEN 0xFF00FF00
#define RGBA_BLUE  0xFFFF0000

#define RGBA_R_INDEX 0
#define RGBA_G_INDEX 1
#define RGBA_B_INDEX 2
#define RGBA_A_INDEX 3

#define RGBA_UNPACK_R(color) (((color) >> (8*RGBA_R_INDEX)) & 0xFF)
#define RGBA_UNPACK_G(color) (((color) >> (8*RGBA_G_INDEX)) & 0xFF)
#define RGBA_UNPACK_B(color) (((color) >> (8*RGBA_B_INDEX)) & 0xFF) 
#define RGBA_UNPACK_A(color) (((color) >> (8*RGBA_A_INDEX)) & 0xFF) 

#define RGBA_PACK_R(color, r) ((color) |= ((r) << (8*RGBA_R_INDEX)))
#define RGBA_PACK_G(color, g) ((color) |= ((g) << (8*RGBA_G_INDEX)))
#define RGBA_PACK_B(color, b) ((color) |= ((b) << (8*RGBA_B_INDEX)))
#define RGBA_PACK_A(color, a) ((color) |= ((a) << (8*RGBA_A_INDEX)))

void rgba32_unpack(uint32_t c, uint8_t comp[4]);
uint32_t rgba32_pack(uint8_t comp[4]);
uint32_t rgba32_mix(uint32_t c1, uint32_t c2);

#endif